File Writing

by: Floyd, 9 years ago


When I write my code like below I receive (unicode error) codec can't decode bytes in position 2-3truncated:escapeUXXXXXXX escape

[text = "Puff the Magic DragonnIsn't real!"
saveFile = open('C:UsersFloydOneDriveDocumentspythonLearningdragonFile.txt','w')
saveFile.write(text)
saveFile.close()]

but if I remove "C:UsersFloydOneDriveDocumentspythonLearning", it writes to the exact spot.



You must be logged in to post. Please login or register an account.



Hey Floyd,

I escape various slashes here, i assume you were using backslashes since its a windows path.

So a backslash in Python is an escape char, if you use just one,  it escapes the next, which is why I remove them, as this is a python website... for example. If you are using backslashes, replace them with forward ones.

-Harrison 9 years ago
Last edited 9 years ago

You must be logged in to post. Please login or register an account.

thanks I totally missed that at the end of the video.

-Floyd 9 years ago

You must be logged in to post. Please login or register an account.